	var myChartA = document.getElementById('main');
	var myChartB = document.getElementById('main1');
//	获取url传值
	function getQueryString(name) {
		var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
		if (result == null || result.length < 1) {return "";}
			return result[1];
		}
		pid = getQueryString("pid");
$(function(){
//		7日打印机打印纸量数据
		myChart7 = echarts.init(myChartA);
		$.ajax({
			type:"get",
			url:serverIP+"/user/printInfo/DayList",
			dataType:"json",
			xhrFields: {
                withCredentials: true    // 设置sessionId相同
            },
			data:{"pId":pid},
			success:function (data){
				var list  =   new Array();
		  	  	var list2 =   new Array(); 
		  	 	var list3 =   new Array();
		  		 
			  	for(var i in data.data){
				    var date =data.data[i].day;
				    date =date.slice(5);
				    list.push(date);
				    list2.push(data.data[i].monoNum);
				    list3.push(data.data[i].colorNum);
				}
			  	myChart7.setOption({
			  		title : {
						text: "近7日打印纸张统计",
						x: "left"
					},
				    tooltip: {
				        trigger: 'axis'
				    },
				    legend: {
				        data:['彩色纸量','黑白纸量'],
				        x:"right",
				        padding:20 
				    },
				    xAxis: [
				        {
				            type: 'category',
				            data: list,
				            axisPointer: {
				                type: 'shadow'
				            }
				        }
				    ],
				    yAxis: [
				        {
				            type: 'value',
				            name: '打印纸张数量',
				        }
				    ],
				    series: [
				        {
				            name:'黑白纸张',
				            type:'bar',
				            itemStyle:{
			                    normal:{
			                        color:'#2F4554'
			                    }
			                },
				            data:list2
				        },
				        {
				            name:'彩色纸张',
				            type:'bar',
				            itemStyle:{
			                    normal:{
			                        color:'#C23531'
			                    }
			                },
				            data:list3
				        } 
				    ]
	  			})
			}
		});
		myChart1 = echarts.init(myChartB);
			$.ajax({
				type:"get",
				url:serverIP+"/user/printInfo/GetLikMargin",
				dataType:"json",
				xhrFields: {
	                withCredentials: true    // 设置sessionId相同
	            },
				data:{"pId":pid},
				success:function (data) {
					var kRest =data.data.kRest;
					var cRest =data.data.cRest;
					var mRest =data.data.mRest;
					var yRest =data.data.yRest;
			    // 填入数据
				    myChart1.setOption({
					    title: {
					        text: '打印机墨盒剩余量图'
					    },
					    tooltip: {},
					    xAxis: {
					        data: ["黑色","青色","红色","黄色"]
					    },
					    yAxis: {
					     	type: 'value',
					    },
					    series: [{
				            name: '本机墨盒剩余百分比',	
				            type: 'bar',
				            data:[kRest,cRest,mRest,yRest],
			                itemStyle: {
				                normal: {
				                    color: function(params) {
				                        var colorList = [
				                          '#000000','#01FFFF','#ED4151','#F7F910'
				                        ];
				                        return colorList[params.dataIndex]
				                    }
				                }
			            	}
				        }]
					});
				}
			});
//	获取打印机签约方式
	$.ajax({  
        type : "get",  
        url : serverIP+"/user/util/GetSignMethodList",  
        xhrFields: {
            withCredentials: true    // 设置sessionId相同
        },
        data:{"pId":pid},
        success : function(data) {
        	if(data.code==0){
        		var u=data.data[0];
        		if(u.payMethod==01){
					var payMethod="包年";
				}else if(u.payMethod==02){
					var payMethod="包月";
				}else if(u.payMethod==03){
					var payMethod="按打印纸张数";
				}else{
					var payMethod=u.payMethod;
				}
				$('.tbody2').html('<tr><td>'+u.name+'</td><td>'+u.monoSinglePrice+'</td><td>'+u.colorSinglePrice+'</td><td>'+u.papeNum+'</td><td>'+payMethod+'</td><td>'+u.deposit+'</td></tr>');
        	}  
        }  
    });
//	获取打预警配置
	$.ajax({  
        type : "post",  
        url : serverIP+"/user/util/GetWarnSetByPrint",  
        xhrFields: {
            withCredentials: true    // 设置sessionId相同
        },
        data:{pId:pid},
        success : function(data) {
        	if(data.code==0){
        		var u=data.data;
        		if(u.cName){}else{u.cName=""};
        		if(u.brand){}else{u.brand=""};
        		if(u.model){}else{u.model=""};
        		if(u.pName){}else{u.pName=""};
				$('.tbody3').html('<tr><td>墨容量下限预警</td><td>'+u.cName +'&nbsp;'+u.brand +'&nbsp;'+ u.model+'&nbsp;'+u.pName+'</td><td>'+u.kRatio+'</td><td>'+u.cRatio+'</td><td>'+u.mRatio+'</td><td>'+u.yRatio+'</td></tr>');
        	}  
        }  
    });
//	获取打墨量总容量
	$.ajax({  
        type : "get",  
        url : serverIP+"/user/printInfo/view",  
        xhrFields: {
            withCredentials: true    // 设置sessionId相同
        },
        data:{printId:pid},
        success:function(data){
        	if(data.code==0){
        		nowStatus=data.data.nowStatus;
        		$('.tbody4').html('<tr><td>'+data.data.printName+'</td><td>墨盒总量值</td><td>'+data.data.kSum+'</td><td>'+data.data.cSum+'</td><td>'+data.data.mSum+'</td><td>'+data.data.ySum+'</td></tr>');
        	}  
        }  
    });
})
$(function(){
	$(".coll_body").eq(0).show();
	$(".coll_body").eq(0).children('a').eq(0).addClass("active");
	$(".Collapsing").eq(0).children('a').children('span').addClass("current");
	$(".Collapsing").eq(0).click(function(){
		$(".Collapsing").eq(0).toggleClass("active");
		$(this).children('.coll_body').children('a').eq(0).toggleClass("active");
	})
	$('.content-center').height($(".admin").height()-51+"px");
	getPaperNum();
})
//监听浏览器窗口变化
window.onresize = function(){
	var bodyH=$("body").height();
	$(".leftbar").height(bodyH-45+"px");
	$(".content").height(bodyH-45+"px");
	$(".admin").height($(".content").height()-45+"px");
//	echarts适应大小
	$('.content-center').height($(".admin").height()-51+"px");
    myChart7.resize();
    myChart1.resize();
}
//故障列表box
$('.set-info').click(function(){
	$('.set-box').toggle();
	$('.set-info').toggleClass('float-right',500);
})
//时间戳转换
$('#beginTime').each(function() {
	var a = new Calendar({
		targetCls: $(this),
		type: 'yyyy-mm-dd',
		wday: 2
	})
});
$('#finishTime').each(function() {
	var a = new Calendar({
		targetCls: $(this),
		type: 'yyyy-mm-dd',
		wday: 2
	})
});
//	查询打印机打印纸量
$('.selectOk').click(function(){
	getPaperNum();
});
function getPaperNum(){
	var beginTime=$('#beginTime').val();
	var finishTime=$('#finishTime').val();
	$.ajax({
		type:"get",
		url:serverIP+"/user/printInfo/GetPrintSumByPrint",
		dataType:"json",
		xhrFields: {
            withCredentials: true    // 设置sessionId相同
        },
		data:{
			pId:pid,
			TimeBegin:beginTime,
			TimeEnd:finishTime
		},
		success:function (data) {
			if(data.data==""){
				alert("这段时间没有打印数据");
				$('.tbody1').html();
			}else{
				$('.tbody1').html('<tr><td>'+data.data[0].pName+'</td><td>'+data.data[0].serial+'</td><td>'+data.data[0].printSum+'</td><td>'+data.data[0].monoSum+'</td><td>'+data.data[0].colorSum+'</td></tr>');
			}
		}
	})
}
//点击维修记录
	$('#maintlist').click(function(){
		window.location.href="errorlist.html?pid="+pid;
	})
